package com.sofwin.service.impl.contents;

import com.sofwin.mapper.*;
import com.sofwin.pojo.*;
import com.sofwin.service.contents.AssetsMainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Project: ssm-parent
 * @Description: 初始化公司主要资产信息
 * @Author : abiao
 * @date Date : 2021年04月27日 上午 10:25
 */
@Service
public class AssetsMainServiceImpl implements AssetsMainService {

    @Autowired
    private CAssetsMainMapper cAssetsMainMapper;
    @Autowired
    private CLanduseMapper cLanduseMapper;
    @Autowired
    private CHouseOwnerMapper cHouseOwnerMapper;
    @Autowired
    private CConstructionMapper cConstructionMapper;
    @Autowired
    private CMainEquipmentMapper cMainEquipmentMapper;
    @Autowired
    private CMainvehiclesMapper cMainvehiclesMapper;

    @Override
    public Integer selectAssetsIdByCompanyId(CAssetsMain cAssetsMain) {
        CAssetsMainExample example = new CAssetsMainExample();
        CAssetsMainExample.Criteria criteria = example.createCriteria();
        criteria.andCompanyIdEqualTo(cAssetsMain.getCompanyId());
        List<CAssetsMain> cAssetsMains = cAssetsMainMapper.selectByExample(example);
        return cAssetsMains.get(0).getId();

    }

    @Override
    public List<CLanduse> selectLandUse(Integer assetsId) {
        CLanduseExample example = new CLanduseExample();
        CLanduseExample.Criteria criteria = example.createCriteria();
        criteria.andAssetsIdEqualTo(assetsId);
        return cLanduseMapper.selectByExample(example);

    }

    @Override
    public List<CHouseOwner> selectHouseOwner(Integer assetsId) {
        CHouseOwnerExample example = new CHouseOwnerExample();
        CHouseOwnerExample.Criteria criteria = example.createCriteria();
        criteria.andAssetsIdEqualTo(assetsId);
        return cHouseOwnerMapper.selectByExample(example);
    }

    @Override
    public List<CConstruction> selectConstruction(Integer assetsId) {
        CConstructionExample example = new CConstructionExample();
        CConstructionExample.Criteria criteria = example.createCriteria();
        criteria.andAssetsIdEqualTo(assetsId);
        return cConstructionMapper.selectByExample(example);

    }

    @Override
    public List<CMainEquipment> selectMainEquipment(Integer assetsId) {
        CMainEquipmentExample example = new CMainEquipmentExample();
        CMainEquipmentExample.Criteria criteria = example.createCriteria();
        criteria.andAssetsIdEqualTo(assetsId);
        return cMainEquipmentMapper.selectByExample(example);

    }

    @Override
    public List<CMainvehicles> selectMainvehicle(Integer assetsId) {
        CMainvehiclesExample example = new CMainvehiclesExample();
        CMainvehiclesExample.Criteria criteria = example.createCriteria();
        criteria.andAssetsIdEqualTo(assetsId);
        return cMainvehiclesMapper.selectByExample(example);
    }
}
